<#import "/master/master-frame.ftl" as master />
<#import "/control/common/splitPage.ftl" as splitPage1 />
<#include "/function.ftl"> 
<@master.masterFrame pageTitle=["人事行政","员工管理","员工列表"]>
	<div class="panel panel-default table-responsive">
		<div class="panel-body">
			<a href="${basePath}/employee/add" class="btn btn-info btn-xs" ><i class="fa fa-plus fa-lg"></i> 新增员工</a>
		</div>
		<div class="panel-heading">条件搜索</div>
		<div class="panel-body">
			<form id="searchForm" class="form-inline no-margin" action="${basePath}/employee/list" method="post">
				<div class="form-group" style="margin-right:10px;">
					<label class="control-label">姓名</label>
					<div>
						<input name="empName" type="text" class="form-control input-sm" value="<#if employee ??>${employee.empName! }</#if>"/>
					</div>
				</div>
				<div class="form-group" style="margin-right:10px;">
					<label class="control-label">手机号码</label>
					<div>
						<input name="phone" type="text" class="form-control input-sm" value="<#if employee ??>${employee.phone! }</#if>"/>
					</div>
				</div>
				<div class="form-group" style="margin-right:10px;">
					<label class="control-label">邮箱</label>
					<div>
						<input name="email" type="text" class="form-control input-sm" value="<#if employee ??>${employee.email! }</#if>"/>
					</div>
				</div>
				<div class="form-group" style="margin-right:10px;">
					<label class="control-label">所在部门</label>
					<div>
						<select class="form-control chzn-select" name="deptId" >
							<option value="">全部</option>
							<#if deptList??>
								<#list deptList as dept>
									<option value="${dept.deptId}" <#if employee?? && (employee.deptId)?? && employee.deptId==dept.deptId>selected</#if>>${dept.deptName}</option>
								</#list>
							</#if>
						</select>
					</div>
				</div>
				<button type="submit" class="btn btn-sm btn-success"><i class="fa fa-search" style="font-size:16px;"></i></button>
			</form>
		</div>
		<table class="table table-bordered table-condensed table-hover table-striped" id="responsiveTable">
			<thead>
				<tr>
					<th>员工编号</th>
					<th>员工名称</th>
					<th>手机</th>
					<th>邮箱</th>
					<th>性别</th>
					<th>生日</th>
					<th>在职状态</th>
					<th>所属部门</th>
					<th>直属上级</th>
					<th>最后登录时间</th>
					<th>账号状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<#if response.empList ??>
					<#list response.empList as emp>
						<tr>
							<td>${emp.empId!}</td>
							<td>${emp.empName!}</td>
							<td>${emp.phone!}</td>
							<td>${emp.email!}</td>
							<td><#if emp.accountType><#if emp.gender?? && emp.gender=="M">男<#else>女</#if></#if></td>
							<td><#if emp.accountType><#if emp.birthday??>${emp.birthday?string('yyyy-MM-dd')}</#if></#if></td>
							<td>
								<#if emp.accountType>
									<#if emp.status==1>
										<span class="label label-success">在职</span>
									<#elseif emp.status==0>
										<span class="label label-warning">离职</span>
									</#if>
								</#if>
							</td>
							<td>${(emp.dept.deptName)!}</td>
							<td><#if emp.accountType>${(emp.leader.empName)!}</#if></td>
							<td><#if emp.lastLoginTime??>${emp.lastLoginTime?string('yyyy-MM-dd HH:mm')}</#if></td>
							<td>
								<#if emp.accountStatus>
									<span class="label label-success">正常</span>
								<#else>
									<span class="label label-danger">禁用</span>
								</#if>
							</td>
							<td>
								<#if hasRight("/employee/edit")>
								<a class="btn btn-xs btn-success" href="${basePath}/employee/edit?empId=${emp.empId}"><i class="fa fa-wrench fa-lg"></i> 编辑</a>
								</#if>
								<#if hasRight("/employee/grantRole")>
									<a class="btn btn-xs btn-warning" href="${basePath}/employee/grantRole?empId=${emp.empId}"><i class="fa fa-wrench fa-lg"></i> 分配角色</a>
								</#if>
								<#if hasRight("/employee/info")>
									<a class="btn btn-xs btn-default" href="${basePath}/employee/info?empId=${emp.empId}"><i class="fa fa-info-circle fa-lg"></i> 查看</a>
								</#if>
								<#if hasRight("/employee/info")>
									<#if emp.accountStatus>
										<button type="button" class="btn btn-xs btn-danger" onclick="lock('${emp.empId}','0');"><i class="fa fa-lock fa-lg"></i> 锁定</button>
									<#else>
										<button type="button" class="btn btn-xs btn-success" onclick="lock('${emp.empId}','1');"><i class="fa fa-unlock fa-lg"></i> 解锁</button>
									</#if>
								</#if>
							</td>
						</tr>
					</#list>
				</#if>
			</tbody>
		</table>
		<@splitPage1.splitPage pageCount=response.splitPage.pageCount pageNo=response.splitPage.pageNo formId="searchForm" recordCount=response.splitPage.recordCount />
	</div><!-- /panel -->
	<script language="javascript">
	function lock(empId,status){
		$.ajax({
			cache: true,
			type: "POST",
			url:"${basePath}/employee/editLock",
			data:"empId=" + empId+"&accountStatus="+status,
			async: false,
			error: function(request) {
				alertify.alert("错误：服务器异常！");
			},
			success: function(data) {
				if(data.success){
					var pageNo=$(".pagination li.active").text();
					$.GoPage(pageNo);
				}
				else{
					alertify.alert("错误:" + data.message);
				}
			}
		});
	}
</script>
</@master.masterFrame>